/*
 * @Author: deliteam 462085920@qq.com
 * @Date: 2023-12-12 09:43:04
 * @Description:
 */
import {
  Controller,
  Post,
  Body,
  Get,
  Query,
  UseGuards,
  Delete,
  Request,
  Put,
  Param,
} from '@nestjs/common';
import { ContactService } from './contact.service';

import { Contact } from './contact.entity';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { JwtAuthGuardUser } from 'src/auth/guards/jwt-auth.guard';
import { CreateContactDto } from './dto/create-contact.dto';
import { RemoveContactDto } from './dto/remove-contact.dto';

import { Log } from 'src/libs/utils';
@ApiTags('联系我们')
@Controller('api/contact')
export class ContactController {
  constructor(private readonly ContactService: ContactService) {}
  @Post()
  @ApiOperation({ summary: '增加' })
  async create(@Body() createContactDto: CreateContactDto): Promise<Contact> {
    return await this.ContactService.create(createContactDto);
  }
  // 删除
  @UseGuards(JwtAuthGuardUser)
  @Delete()
  @ApiOperation({ summary: '删除' })
  async remove(
    @Body() removeContactDto: RemoveContactDto,
    @Request() req,
  ): Promise<any> {
    Log({ req });
    return await this.ContactService.delete(removeContactDto);
  }
  @Get()
  @ApiOperation({ summary: '列表' })
  async findAll(@Query() query: any): Promise<Contact> {
    return await this.ContactService.findAll(query);
  }
}
